#!/bin/sh
npm run release
versionName=$1;
versionCode=$2;
count=$3;
versionLog=$4;
buildType=$5;
passwordUrl=/Users/cuipengfei/.ssh/id_rsa
lastRpkName=com.youth.kandianquickapp.release.rpk
timeStamp=`date '+%Y%m%d%H%M%y'`  


commitId=git rev-parse HEAD
echo $commitId

rpkUrl=http://fastapp.tgfwe.com/h5/fastrpk/${buildType}/

rm -rf rpk/*
cp -R dist/$lastRpkName  rpk/
mv rpk/$lastRpkName rpk/$versionName"_"$versionCode"_"${count}".rpk"

# 发送文件到测试服
function transferFileToTestSever(){
    echo "[exec]transfer file to development::123.56.12.26"
    ssh -i $passwordUrl www@123.56.12.26 "test -e /web/website/fast_app.tgfwe.com/h5/fastrpk/$buildType || mkdir /web/website/fast_app.tgfwe.com/h5/fastrpk/$buildType"
    scp -r -i $passwordUrl ./rpk/* www@123.56.12.26:/web/website/fast_app.tgfwe.com/h5/fastrpk/$buildType
}


rpkUrl=${rpkUrl}$versionName"_"$versionCode"_"${count}".rpk"
# echo '获取到rpk地址:'${rpkUrl}$versionName"_"$versionCode"_"${timeStamp}".rpk"


#向钉钉发送消息方法
function SendMessageToDingding(){
    # 发送钉钉消息
    curl "${Dingding_Url}" -t utf-8    -H 'Content-Type: application/json;charset=utf-8' -d "
    {
     \"msgtype\":\"text\",
     \"text\":{\"content\":\"${Body}\"},
     \"at\":{\"atMobiles\":[\"15801314850\",\"178xxxx83xx\",\"151xxxx17xx\",\"176xxxx95xx\"],\"isAtAll\":false}
    }"
}
#钉钉机器人url
Dingding_Url="https://oapi.dingtalk.com/robot/send?access_token=70bab4065a827ae766f38b43578c526a5bdd20a9b2a4ce1ea169c02a72eef6ac"
#钉钉机器人内容格式
Body="温馨提示:快应用更新了"${rpkUrl}
echo $Body
transferFileToTestSever
#调用发送方法
# SendMessageToDingding $Body $Dingding_Url
# transferFileToTestSever